[g]cc [flags] files -lsipp -lm [ libraries ]
This manual gives a short description the set of shaders beside basic_shader() that are included in the library. All shaders described here, except strauss_shader() and phong_shader() provide some kind of special effect on a surface and call basic_shader() to do the actual shading calculations. See the user manual for a detailed description of the shaders.
The surface description used in strauss_shader() is called
Strauss_desc and looks like this:
typedef struct {
double ambient;
double smoothness;
double metalness;
Color color;
Color opacity;
} Strauss_desc;
ambient is a value between 0 and 1 which determines how much of the base
color of a surface that is visible when it is not illuminated by any
lightsource.
smoothness is a value between 0 and 1 that describes how smooth the
surface is. This parameter controls both diffuse and specular reflections. 0
means a dull surface while 1 means a very smooth and shiny one.
metalness is alo a value between 0 and 1. It describes how metallic the
material is. It controls among other things how much of the surface color
should be mixed into the specular reflections at different angles. 0 means a
non-metal while 1 means a very metallic surface.
color is (of course) the base color of the surface.
opacity specifies how opaque the surface is. This is stored as a
color to allow different opacities for the different color bands.
The surface description for a wood surface is called
Wood_desc and is defined as follows:
typedef struct {
double ambient;
double specular;
double c3;
double scale;
Color base;
Color ring;
Color opacity;
} Wood_desc;
Except for the two colors and the field scale, Wood_desc
looks exactly like a Surf_desc and the fields are used in the
same way.
scale is a factor which determines the size of the
wood pattern depending on the size of the texture coordinate system
in relation to the world coordinate system. You will have to
experiment some to get this right.
base is the color of the base material, and ring is the
color of the darker rings.
opacity specifies how opaque the surface is. This is stored as a
color to allow different opacities for the different color bands.
The surface description for a marble surface is called
Marble_desc and is defined as follows:
typedef struct {
double ambient;
double specular;
double c3;
double scale;
Color base;
Color strip;
Color opacity;
} Marble_desc;
Except for the two colors and the field scale, Marble_desc
looks exactly like a Surf_desc and the fields are used in the
same way.
scale is a factor which determines the size of the
marble pattern depending on the size of the texture coordinate system
in relation to the world coordinate system.
base is the color of the base material, and strip is the
color of the interspersed material.
opacity specifies how opaque the surface is. This is stored as a
color to allow different opacities for the different color bands.
The surface description used in granite_shader() is called
Granite_desc and is defined as follows:
typedef struct {
double ambient;
double specular;
double c3;
double scale;
Color col1;
Color col2;
Color opacity;
} Granite_desc;
The fields have the same meaning as in Marble_desc.
The surface description is called Bozo_desc and is defined as
follows:
typedef struct {
Color *colors;
int no_of_cols;
double ambient;
double specular;
double c3;
double scale;
Color opacity;
} Bozo_desc;
colors is a pointer to an array of Color structs and no_of_cols defines the number of entries in this array. The other fields have the same function as in the prevoiusly described shaders.
The surface description is called Mask_desc and has the
following definition:
typedef struct {
Shader *t_shader;
void *t_surface;
Shader *f_shader;
void *f_surface;
void *mask_data;
bool (*masker)();
} Mask_desc;
t_shader is used together with the surface description
t_surface when masker() returns TRUE.
f_shader is used together with the surface description
f_surface when masker() returns FALSE.
mask_data is a pointer to the data that the decision function need.
masker is the decision function.
The surface description is called Bumpy_desc and is defined as
follows:
typedef struct {
Shader *shader;
void *surface;
double scale;
bool bumpflag;
bool holeflag;
} Bumpy_desc;
shader and surface define the shader to be used for the
final shading calculations.
scale has the same meaning as in previous shaders using noise().
bumpflag and holeflag make it possible to flatten out
half of the bumps. If only bumpflag is TRUE only bumps "standing
out" from the surface are visible. The rest of the surface will be smooth.
If, on the other hand, only holeflag is TRUE only bumps going
"into" the surface will be visible, thus giving the surface an
eroded look. If both flags are true, the whole surface will get a
bumpy appearence, rather like an orange.
The texture is 3-dimensional, so it is possible to create cube planets or even planets with cut-out parts that still have surfaces that resemble the earth surface. The texture is not scalable, and is designed to be used with texture coordinats in the range -1.0 to 1.0, e.g. a unit sphere. Of course the world coordinats need not have the same order of magnitude.
planet_shader() uses an ordinary Surf_desc in which the color field is ignored.